 <template>
 <div>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
  <el-form-item label="姓氏查询">
    <el-input v-model="query.surname" placeholder="请输入姓氏"></el-input>
  </el-form-item>
  <el-form-item label="部门查询">
    <el-select v-model="query.deptId" placeholder="部门">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">查询</el-button>
  </el-form-item>
</el-form>
    <el-table
      :data="staffList"
      style="width: 100%">
      <el-table-column
        prop="sname"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="age"
        label="年龄"
        width="180">
      </el-table-column>
      <el-table-column
        prop="deptId"
        label="部门">
      </el-table-column>

    </el-table>
          <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="query.total"
    >
    </el-pagination>
</div>
  </template>

<script>
export default {
  data() {
    return {
        staffList:[],
        query:{
          pageNum:1,
          pageSize:5,
          total:0,
          surname:''
        },
    };
  },
  methods: {
    selAll(){
        this.$axios.post("http://localhost:8999/staff/selAll",this.query).then(res=>{
            this.staffList = res.data.data.staffs;
            this.query.total = res.data.data.page;
        })
    },
     onSubmit() {
        this.selAll();
      },
      handleSizeChange(val) {
      this.query.pageSize = val;
      this.selAll();
    },
    handleCurrentChange(val) {
      this.query.pageNum = val;
      this.selAll();
    },
  },
  mounted() {
    this.selAll();
  }
};
</script>